package com.example.Lezedata.ui.orderPage;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.example.Lezedata.R;
import com.example.Lezedata.util.GBTimeManager;

import bid.Bid;

public class OrderListCell extends LinearLayout {

    public Bid.NodeOrder pool;

    private TextView textViewOrderNumber;
    private TextView textViewTime;
    private TextView textViewBuyType;
    private TextView textViewNodeCount;
    private TextView textViewDays;

    private LinearLayout lineBaseLineBuyType;
    public static OrderListCell newInstance(Context context , ViewGroup viewGroup) {
        OrderListCell cell = (OrderListCell)LayoutInflater.from(context).inflate(R.layout.order_list_cell,viewGroup,false);
        return cell;
    }

    public OrderListCell(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
         textViewOrderNumber = findViewById(R.id.textView_orderid);

        textViewBuyType= findViewById(R.id.textView_buytype);
        textViewNodeCount  = findViewById(R.id.textView_nodecount);
        textViewDays   = findViewById(R.id.textView_daycount);
        textViewTime   = findViewById(R.id.textView_bindtime);
    }

    public void setPool(Bid.NodeOrder pool) {
        this.pool = pool;
        textViewOrderNumber.setText(String.valueOf(pool.getId()));
        textViewTime.setText(GBTimeManager.timesYMD_HMS(pool.getCreateTime()));
       String str = "";
        switch (pool.getBuyType()){
            case NOBT_ADMIN:
                str = "人工";
                break;
            case NOBT_PAY:
                str = "APP";
                break;
        }
        textViewBuyType.setText(str);
        textViewNodeCount.setText(String.valueOf(pool.getNodeCount()));
        textViewDays.setText(String.valueOf(pool.getDayCount()));
    }
}
